package spike.s003.sqlflow.entity;

import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.RowMapper;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Date;

/**
 * Created by ylyang on 04/04/2017.
 */
public class QQEntity {
    private String qqNum;
    private String qqName;
    private Date createTime;

    public String getQqNum() {
        return qqNum;
    }

    public void setQqNum(String qqNum) {
        this.qqNum = qqNum;
    }

    public String getQqName() {
        return qqName;
    }

    public void setQqName(String qqName) {
        this.qqName = qqName;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public static class BeanRowMapper implements RowMapper {
        private static final BeanPropertyRowMapper<QQEntity> MAPPER = BeanPropertyRowMapper.newInstance(QQEntity.class);

        public static QQEntity mapRow(ResultSet rs) throws SQLException {
            QQEntity qqEntity = MAPPER.mapRow(rs, rs.getRow());
            qqEntity.setQqNum(rs.getString("qq_num"));
            qqEntity.setQqName(rs.getString("qq_name"));
            qqEntity.setCreateTime(rs.getDate("create_time"));
            return qqEntity;
        }

        @Override
        public QQEntity mapRow(ResultSet rs, int rowNum) throws SQLException {
            return mapRow(rs);
        }
    }

    @Override
    public String toString() {
        return "QQEntity{" +
                "qqNum='" + qqNum + '\'' +
                ", qqName='" + qqName + '\'' +
                ", createTime=" + createTime +
                '}';
    }
}
